# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

_pyname=claripy
pkgname=python-${_pyname}
pkgver=9.2.47
pkgrel=1
pkgdesc='Abstraction layer for constraint solvers'
url='https://github.com/angr/claripy'
license=('custom:BSD2')
arch=('any')
depends=(
  'python'
  'python-cachetools'
  'python-decorator'
  'python-pysmt'
  'python-z3-solver'
)
makedepends=(
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
checkdepends=('python-pytest')
source=("${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha512sums=('5a98c08ea12b050112a5ea0fa3768540240fd60736c03bca58a6b60c094caa2bea636b887da011aa2f88028225839938ef8c015eb8a6e57cb9e6deb3ee504c19')
b2sums=('3fcd4889b6d4a26e31e3ed407dd31bae0fb97060c54ce3699e4eba5986f0db4122f8e6fb48eb4d0d17e1ea49472fc74edbf35b6b8fbdb0091d9e695b7ffb8546')

prepare() {
  # we don't support version pinning
  sed -e 's/==/>=/' -i $_pyname-$pkgver/setup.cfg
}

build() {
  cd ${_pyname}-${pkgver}
  python -m build --wheel --no-isolation
}

check() {
  local pytest_options=(
    -vv
    # disable broken tests: https://github.com/angr/claripy/issues/348
    --deselect tests/test_solver.py::StandardTests::test_simplification_annotations
    --deselect tests/test_solver.py::TestSolver::test_solver_with_reuse
    --deselect tests/test_solver.py::TestSolver::test_solver_without_reuse
    --deselect tests/test_solver.py::TestSolverReplacement::test_solver_with_reuse
    --deselect tests/test_solver.py::TestSolverReplacement::test_solver_without_reuse
    --deselect tests/test_solver.py::TestHybrid::test_solver_with_reuse
    --deselect tests/test_solver.py::TestHybrid::test_solver_without_reuse
    --deselect tests/test_solver.py::TestComposite::test_solver_with_reuse
    --deselect tests/test_solver.py::TestComposite::test_solver_without_reuse
    --deselect tests/test_solver.py::TestSolverCacheless::test_solver_with_reuse
    --deselect tests/test_solver.py::TestSolverCacheless::test_solver_without_reuse
  )

  cd ${_pyname}-${pkgver}
  PYTHONPATH=build/lib pytest "${pytest_options[@]}"
}

package() {
  cd ${_pyname}-${pkgver}
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
}

# vim: ts=2 sw=2 et:
